package com.hksj.app.websocket;


/**
 * 消息类型
 */
public enum MessageType {
    REPORT_PROPERTY("report_property","设备属性上报"),

    REPORT_PROPERTY_REPLY("report_property_reply","设备属性上报回复"),

    ASK_FOR_HELP("ask_for_help","紧急求助"),

    ASK_FOR_HELP_REPLY("ask_for_help_reply","紧急求助回复"),

    ASK_FOR_HELP_BROADCAST("ask_for_help_broadcast","紧急求助广播"),

    CALL_CLEAR("call_clear","呼叫清洁"),

    CALL_CLEAR_REPLY("call_clear_reply","呼叫清洁回复"),

    CONNECT_REPLY("connect_reply","连接回复"),

    EQ_CONTROL("eq_control","设备控制");

    private final String code;
    private final String remark;

    MessageType(String code, String remark){
        this.code = code;
        this.remark = remark;
    }

    public String value(){
        return this.code;
    }

    public String remark(){return this.remark;}


    public static String getCodeByRemark(String remark){
        for (MessageType messageType : values()) {
            if (messageType.remark().equals(remark)) {
                return messageType.value();
            }
        }
        return null;
    }

    public static String getRemarkByCode(String code){
        for (MessageType messageType : values()) {
            if (messageType.value().equals(code)) {
                return messageType.remark();
            }
        }
        return null;
    }

}
